#{extends 'main.html' /} 
#{set title:messages.get("deal.admin.text") /}
<h1>Deals</h1>


<a href="@{DealsAdmin.newDeal()}"><button class="newDeal">&{'deal.admin.new.deal'}</button></a>
 
 
#{ifnot myDeals}
    <p>
        &{'deal.admin.no.deals'}
    </p>
#{/ifnot}
#{else}
   <table>
       <thead>
           <tr>
               <th>&{'deal.title'}</th>
               <th width="300">&{'deal.admin.deal.description'}</th>
               <th width="85">&{'deal.admin.deal.startDate'}</th>
               <th width="85">&{'deal.admin.deal.endDate'}</th>
               <th width="170">&{'deal.admin.deal.options'}</th>
           </tr>
       </thead>
       <tbody>
           #{list myDeals, as:'deal'}
               <tr>
                   <td><a href="@{Deals.viewDeal(deal.id)}">${deal.title}</a></td>
                   <td>${deal.description.length() > 40 ? deal.description[0..40] + '…' : deal.description}</td>
                   <td style="color:#777">${deal.startDate.format()}</td>
                   <td style="color:#777">${deal.endDate.format()}</td>
                   <td>
                   #{a @editDeal(deal.id)}<button class="button edit">&{'deal.admin.deal.options.edit'}</button>#{/a}
				   <button class="button delete" onclick="if(confirm('&{'deal.admin.deal.options.delete.query'}')) window.location.href='@{deleteDeal(deal.id)}';">&{'deal.admin.deal.options.delete'}</button>
                   </td>
               </tr>
           #{/list}
       </tbody>
   </table> 
#{/else}